home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / MacPNG Library 1.02 / pngMacSrc 1.02 / PNG Library 0.80 / zLib 0.95 / zutil.h < prev   
Encoding:
C/C++ Source or Header  |  1996-05-29  |  4.4 KB  |  197 lines  |  [TEXT/ttxt]

  1. /* zutil.h -- internal interface and configuration of the compression library
  2.  * Copyright (C) 1995 Jean-loup Gailly.
  3.  * For conditions of distribution and use, see copyright notice in zlib.h
  4.  */
  5.  
  6. /* WARNING: this file should *not* be used by applications. It is
  7.    part of the implementation of the compression library and is
  8.    subject to change. Applications should only use zlib.h.
  9.  */
  10.  
  11. /* $Id: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp $ */
  12.  
  13. #ifndef _Z_UTIL_H
  14. #define _Z_UTIL_H
  15.  
  16. #include "zlib.h"
  17.  
  18. #if defined(MSDOS) || defined(VMS)
  19. #   include <stddef.h>
  20. #   include <errno.h>
  21. #else
  22.     extern int errno;
  23. #endif
  24. #if defined(MACOS)
  25. #    include <stdlib.h>
  26. #    include <unix.h>
  27. #endif
  28. #ifdef STDC
  29. #  include <string.h>
  30. #endif
  31.  
  32. #ifndef local
  33. #  define local static
  34. #endif
  35. /* compile with -Dlocal if your debugger can't find static symbols */
  36.  
  37. typedef unsigned char  uch;
  38. typedef uch FAR uchf;
  39. typedef unsigned short ush;
  40. typedef ush FAR ushf;
  41. typedef unsigned long  ulg;
  42.  
  43. extern char *z_errmsg[]; /* indexed by 1-zlib_error */
  44.  
  45. #define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err)
  46. /* To be used only when the state is known to be valid */
  47.  
  48.         /* common constants */
  49.  
  50. #define DEFLATED   8
  51.  
  52. #ifndef DEF_WBITS
  53. #  define DEF_WBITS MAX_WBITS
  54. #endif
  55. /* default windowBits for decompression. MAX_WBITS is for compression only */
  56.  
  57. #if MAX_MEM_LEVEL >= 8
  58. #  define DEF_MEM_LEVEL 8
  59. #else
  60. #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
  61. #endif
  62. /* default memLevel */
  63.  
  64. #define STORED_BLOCK 0
  65. #define STATIC_TREES 1
  66. #define DYN_TREES    2
  67. /* The three kinds of block type */
  68.  
  69. #define MIN_MATCH  3
  70. #define MAX_MATCH  258
  71. /* The minimum and maximum match lengths */
  72.  
  73.         /* target dependencies */
  74.  
  75. #ifdef MSDOS
  76. #  define OS_CODE  0x00
  77. #  ifdef __TURBOC__
  78. #    include <alloc.h>
  79. #  else /* MSC or DJGPP */
  80. #    include <malloc.h>
  81. #  endif
  82. #endif
  83.  
  84. #ifdef OS2
  85. #  define OS_CODE  0x06
  86. #endif
  87.  
  88. #ifdef WIN32 /* Windows NT */
  89. #  define OS_CODE  0x0b
  90. #endif
  91.  
  92. #if defined(VAXC) || defined(VMS)
  93. #  define OS_CODE  0x02
  94. #  define FOPEN(name, mode) \
  95.      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
  96. #endif
  97.  
  98. #ifdef AMIGA
  99. #  define OS_CODE  0x01
  100. #endif
  101.  
  102. #if defined(ATARI) || defined(atarist)
  103. #  define OS_CODE  0x05
  104. #endif
  105.  
  106. #ifdef MACOS
  107. #  define OS_CODE  0x07
  108. #endif
  109.  
  110. #ifdef __50SERIES /* Prime/PRIMOS */
  111. #  define OS_CODE  0x0F
  112. #endif
  113.  
  114. #ifdef TOPS20
  115. #  define OS_CODE  0x0a
  116. #endif
  117.  
  118.         /* Common defaults */
  119.  
  120. #ifndef OS_CODE
  121. #  define OS_CODE  0x03  /* assume Unix */
  122. #endif
  123.  
  124. #ifndef FOPEN
  125. #  define FOPEN(name, mode) fopen((name), (mode))
  126. #endif
  127.  
  128.          /* functions */
  129.  
  130. #ifdef HAVE_STRERROR
  131.    extern char *strerror OF((int));
  132. #  define zstrerror(errnum) strerror(errnum)
  133. #else
  134. #  define zstrerror(errnum) ""
  135. #endif
  136.  
  137. #if defined(pyr)
  138. #  define NO_MEMCPY
  139. #endif
  140. #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
  141.  /* Use our own functions for small and medium model with MSC <= 5.0.
  142.   * You may have to use the same strategy for Borland C (untested).
  143.   */
  144. #  define NO_MEMCPY
  145. #endif
  146. #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  147. #  define HAVE_MEMCPY
  148. #endif
  149. #ifdef HAVE_MEMCPY
  150. #  if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */
  151. #    define zmemcpy _fmemcpy
  152. #    define zmemzero(dest, len) _fmemset(dest, 0, len)
  153. #  else
  154. #    define zmemcpy memcpy
  155. #    define zmemzero(dest, len) memset(dest, 0, len)
  156. #  endif
  157. #else
  158.    extern void zmemcpy  OF((Bytef* dest, Bytef* source, uInt len));
  159.    extern void zmemzero OF((Bytef* dest, uInt len));
  160. #endif
  161.  
  162. /* Diagnostic functions */
  163. #ifdef DEBUG
  164. #  include <stdio.h>
  165. #  ifndef verbose
  166. #    define verbose 0
  167. #  endif
  168. #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  169. #  define Trace(x) fprintf x
  170. #  define Tracev(x) {if (verbose) fprintf x ;}
  171. #  define Tracevv(x) {if (verbose>1) fprintf x ;}
  172. #  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  173. #  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  174. #else
  175. #  define Assert(cond,msg)
  176. #  define Trace(x)
  177. #  define Tracev(x)
  178. #  define Tracevv(x)
  179. #  define Tracec(c,x)
  180. #  define Tracecv(c,x)
  181. #endif
  182.  
  183.  
  184. typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
  185.  
  186. extern void z_error    OF((char *m));
  187.  
  188. voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
  189. void   zcfree  OF((voidpf opaque, voidpf ptr));
  190.  
  191. #define ZALLOC(strm, items, size) \
  192.            (*((strm)->zalloc))((strm)->opaque, (items), (size))
  193. #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  194. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  195.  
  196. #endif /* _Z_UTIL_H */
  197.